package cn.jingzhuan.fm.di.injection

import android.support.v4.app.Fragment
import cn.jingzhuan.element.demo.view.fragment.FMAudioIntroFragment
import cn.jingzhuan.element.demo.view.fragment.FMAudioListFragment
import cn.jingzhuan.fm.di.component.FMAudioCommentSendComponent
import cn.jingzhuan.fm.di.component.FMAudioListComponent
import cn.jingzhuan.fm.di.scope.FragmentScope
import cn.jingzhuan.fm.ui.fragment.FMAudioCommentSendFragment
import cn.jingzhuan.fm.ui.fragment.FMAudioPlayListFragment
import dagger.Binds
import dagger.Module
import dagger.android.AndroidInjector
import dagger.android.ContributesAndroidInjector
import dagger.android.support.FragmentKey
import dagger.multibindings.IntoMap

@Module(
        subcomponents =  [
            FMAudioListComponent::class,
            FMAudioCommentSendComponent::class
        ])
abstract class FragmentModule {

    @FragmentScope
    @ContributesAndroidInjector
    internal abstract fun contributeFMAudioIntroFragmentInjector(): FMAudioIntroFragment

    @FragmentScope
    @ContributesAndroidInjector
    internal abstract fun contributeFMAudioPlayListFragmentInjector(): FMAudioPlayListFragment

    @Binds
    @IntoMap
    @FragmentKey(FMAudioListFragment::class)
    internal abstract fun contributeFMAudioListFragmentInjector(builder: FMAudioListComponent.Builder): AndroidInjector.Factory<out Fragment>

    @Binds
    @IntoMap
    @FragmentKey(FMAudioCommentSendFragment::class)
    internal abstract fun contributeFMAudioCommentSendFragmentInjector(builder: FMAudioCommentSendComponent.Builder): AndroidInjector.Factory<out Fragment>

}